package edu.towson.cosc603.coffeemaker;
 

 
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
 

 
/**
 * The Class CoffeeMakerTest.
 */
public class CoffeeMakerTest extends TestCase {
 
        private Recipe recipe1;
        private CoffeeMaker coffeeMaker;
 
        /* (non-Javadoc)
         * @see junit.framework.TestCase#setUp()
         */
        @Before
 
        public void setUp() throws Exception{
 
                coffeeMaker = new CoffeeMaker(); 
                recipe1 = new Recipe();
                recipe1.setName("coffee");
                recipe1.setAmtChocolate(1);
                recipe1.setAmtCoffee(2);
                recipe1.setAmtMilk(3);
                recipe1.setAmtSugar(4);
                recipe1.setPrice(5);
          new Inventory();
 
        }

        @After
        public void tearDown() throws Exception{
 
                coffeeMaker = null;
                recipe1 = null;
        }
        
        /**
         * Test add recipe1. trach the coffee maker.class add recipe
         */
        @Test
        public void testAddRecipe1(){
        	recipe1 = new Recipe();
            recipe1.setName("coffee");
            recipe1.setAmtChocolate(1);
            recipe1.setAmtCoffee(2);
            recipe1.setAmtMilk(3);
            recipe1.setAmtSugar(4);
            recipe1.setPrice(5);
             assertEquals(true,coffeeMaker.addRecipe(recipe1));
        }

        /**
         * Test delete recipe1.
         */
        @Test
        public void testDeleteRecipe1(){
        	
                coffeeMaker.addRecipe(recipe1);
                assertEquals(true,coffeeMaker.deleteRecipe(recipe1));
                Recipe recipe2 = new Recipe();              
                assertEquals(false,coffeeMaker.deleteRecipe(recipe2));
                assertEquals(false,coffeeMaker.deleteRecipe(null));
        }
        
        /**
         * Test edit recipe1. in the function there are two situation if the recipe changed
         */
        public void testEditRecipe1(){
               coffeeMaker.addRecipe(recipe1);
               Recipe recipe2 = new Recipe();
               recipe2.setName("coffee2"); 
               recipe2.setAmtChocolate(1);
               recipe2.setAmtCoffee(2);
               recipe2.setAmtMilk(4);
               recipe2.setAmtSugar(2);
               recipe2.setPrice(5);
           assertEquals(false,coffeeMaker.editRecipe(recipe1,recipe2));       
             Recipe recipe3 = new Recipe();
             recipe3.setName("coffee"); 
             recipe3.setAmtChocolate(1);
             recipe3.setAmtCoffee(2);
             recipe3.setAmtMilk(3);
             recipe3.setAmtSugar(4);
             recipe3.setPrice(5);
             assertEquals(true,coffeeMaker.editRecipe(recipe1,recipe3));
        
        }
 
        /**
         * Test add inventory. need to test return true and false situation
         */
        @Test
 
        public void testAddInventory(){
 
                int newAmntSugar = 25;
                int newAmntMilk = 25;
                int newAmntCoffee = 25;
                int newAmntChocolate = 25;
                assertEquals(false,coffeeMaker.addInventory(newAmntCoffee, newAmntMilk, newAmntSugar, newAmntChocolate));           
  
                int newAmntSugar1 = -25;
                int newAmntMilk1 = 25; 
                int newAmntCoffee1 = 25;
                int newAmntChocolate1 = 25;
                assertEquals(true,coffeeMaker.addInventory(newAmntCoffee1, newAmntMilk1, newAmntSugar1, newAmntChocolate1));
                
              
        }
       
        /**
         * Test make coffee.
         */
        @Test
        public void testMakeCoffee(){
                coffeeMaker.addRecipe(recipe1);
                coffeeMaker.addInventory(recipe1.getAmtCoffee(), recipe1.getAmtMilk(), recipe1.getAmtSugar(), recipe1.getAmtChocolate());
                assertEquals(1, coffeeMaker.makeCoffee(recipe1, 1));
                
                Recipe recipe4 = new Recipe(); 
                recipe4.setName("coffee");
                recipe4.setAmtChocolate(50);
                recipe4.setAmtCoffee(50); 
                recipe4.setAmtMilk(50);
                recipe4.setAmtSugar(50);
                recipe4.setPrice(10);
                coffeeMaker.addRecipe(recipe4);
                coffeeMaker.addInventory(15,15,15,15);
                assertEquals(10, coffeeMaker.makeCoffee(recipe4, recipe4.getPrice()));
 
        }
 
      
 
        public void testEnoughMoneyInserted(){
 
                coffeeMaker.addRecipe(recipe1);
 
                coffeeMaker.addInventory(recipe1.getAmtCoffee(), recipe1.getAmtMilk(), recipe1.getAmtSugar(), recipe1.getAmtChocolate());
 
                assertEquals(5, coffeeMaker.makeCoffee(recipe1, 10));
 
        }

        @Test
 
        public void testGetRecipeName(){
                coffeeMaker.addRecipe(recipe1);
                assertEquals(recipe1, coffeeMaker.getRecipeForName("coffee"));
 
        }
 

 
}
 
